package com.zh.controller;


import com.zh.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;

/**
 * 邮件服务
 */
@RestController
@CrossOrigin  // 跨域支持
public class EmailController {

    @Autowired
    private EmailService emailService;

    @GetMapping("/email-send-simple/{to}/{code}")
    public Boolean sendSimpleEmail(@PathVariable String to, @PathVariable String code){
        return emailService.sendSimpleEmail(to,code);
    }

    @GetMapping("/email-send-html/{to}/{code}")
    public Boolean sendHtmlEmail(@PathVariable String to, @PathVariable String code) throws MessagingException {
        return emailService.sendHtmlEmail(to,code);
    }
}
